<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link rel="stylesheet" href="css/base.css" type="text/css" />
<script type="text/javascript" src="js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="js/jquery-form.js"></script>
<script type="text/javascript">
	$(function(){
		//异步提交缩略图 
		$('#head').change(function(){
			$('#up_image').ajaxSubmit({
  				url:"picture_upImage.action",   	//发送请求的url地址
  				dataType:"text",			//返回
  				success:function(data){ 	//当请求之后调用。传入返回后的数据，以及包含成功代码的字符串。
  					$('#soul').attr('src',"picture_image/"+data);   //拿被选中的src属性，并设置
  					$('#v_head').val(data);	//隐藏框 拿到返回的data值  				
  				}
			})
		});
		
			//准备数据，准备保存
			$('.submit').click(function(){
					var flag = true;
					if (!$('#intro').val()) {
						$('#intro').focus();
						$('#intro').next().html("输入值不能为空");
						flag = false;
						return false;
					}
					$('#intro').next().html("");
				//给上传图片名字属性赋值
				var Name = $('#soul').attr('src');
				var pictureName = Name.substring(14);
				

			if (flag) {
				//修改学生信息
				var id = <%=request.getParameter("id") %> 
					$.ajax({
						url:"picture_update.action?id="+id,		
						type:"post",
						dataType:"json",
						data:{
							"intro":$('#intro').val(),
							"pictureName": pictureName
						},
						success:function(data){
							if ('EC001' == data.code){
							 	alert("修改信息成功");
								window.location.href="picture_showInfo.action";	
							} else {
								alert("修改信息失败，请重试!");
							}
						}
					})
			}
			 
			 
		});
		
		
	});


</script>
</head>

<body>
		<div class="main_right_top">您现在所在位置 > <span>修改实训图信息</span></div>
		<div class="main_right_body"> 
        <div class="body_content">
        	<div class="add_xm_all">
            	<h1 class="add_xm_top">
                	实训图信息
                </h1><!--add_xm_top-->
                
            	<div class="add_xm_form">
                	<ul>                        
						<li>
                            <label>实训图简介：</label>
                            <input type="text" value="${picturePO.img_intro}" id="intro"/>		
                        </li>
                         <li>
                            <label>上传照片：</label>
                            <input type="hidden" name="head" id="v_head"/>
                            <form action="picture_upImage.action" method="post" enctype="multipart/form-data" id="up_image">
				      			<input type="file" id="head" name="image"/>
				      		</form>
							<span>
				      			<img src="" id="soul" name="picture">
				      		</span>
				      	</li>
				     </ul>
                    <div class="regist_btn">
                        <input type="submit" value="提交" class="submit" />
                        <a class="return_btn">返回</a>
                    </div>
                </div><!--add_xm_form-->
            </div><!--add_xm_all-->
       </div>	
	</div> <!--main_right_body-->
	
</body>
</html>
